
//
//  Created by 谢忠敏 on 15/7/22.
//  Copyright (c) 2015年 谢忠敏. All rights reserved.
//

#import "XZMTabBarViewController.h"

#import "HomeViewController.h" //首页
#import "IntelligenceViewController.h"//智能
#import "UserViewController.h"//用户


#import "AroundViewController.h"
#import "WuyefuwuViewController.h"
#import "ShequhudongViewController.h"

@interface XZMTabBarViewController ()

@end

@implementation XZMTabBarViewController

+ (void)initialize
{
    // 通过appearance统一设置所有UITabBarItem的文字属性
    UITabBarItem *tabBarItem = [UITabBarItem appearance];
    
    /** 设置默认状态 */
    NSMutableDictionary *norDict = @{}.mutableCopy;
    norDict[NSFontAttributeName] = [UIFont systemFontOfSize:14];
    norDict[NSForegroundColorAttributeName] = [UIColor grayColor];
    [tabBarItem setTitleTextAttributes:norDict forState:UIControlStateNormal];
    
    /** 设置选中状态 */
    NSMutableDictionary *selDict = @{}.mutableCopy;
    selDict[NSFontAttributeName] = norDict[NSFontAttributeName];
    selDict[NSForegroundColorAttributeName] = [UIColor blackColor];
    [tabBarItem setTitleTextAttributes:selDict forState:UIControlStateSelected];
}




- (void)viewDidLoad {
    [super viewDidLoad];

    
    
    UIButton *button=[[UIButton alloc]init];
    button.frame=CGRectMake(0, 0, 375, 64);
    button.backgroundColor=[UIColor colorWithRed: 230/255.0 green:55/255.0 blue:55/255.0 alpha:1.0];
    [self.view addSubview:button];
    
    
    UILabel *labletext=[[UILabel alloc]init];
    labletext.frame=CGRectMake(155, 34, 66, 14);
    labletext.text=@"星河国际";
    labletext.adjustsFontSizeToFitWidth=YES;
    labletext.textColor=[UIColor whiteColor] ;
    [self.view addSubview:labletext];
    
    
    
    UIButton *button1=[[UIButton alloc]init ];//]WithFrame:CGRectMake(50, 50, 20, 20)];
    button1.frame=CGRectMake(22, 35, 20, 20);
    [button1 setBackgroundImage:[UIImage imageNamed:@"return@2x.png"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(fanhui:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];

    
    /*
     
     intelligenceNav.tabBarItem.image = [[UIImage imageNamed:@"社区互动状态@2x.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
     intelligenceNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"社区互动状态1@2x.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

     
     */
    

    [self setUpChildControllerWith:[[WuyefuwuViewController alloc]init] norImage:[UIImage imageNamed:@"物业服务状态@2x.png"] selImage:[UIImage imageNamed:@"物业服务状态1@2x.png"] title:@"物业服务"];
    
    /** 新帖 */
    [self setUpChildControllerWith:[[ShequhudongViewController alloc] init] norImage:[UIImage imageNamed:@"社区互动状态@2x.png"] selImage:[UIImage imageNamed:@"社区互动状态1@2x.png"]title:@"社区互动"];
    
    /** 关注 */
    [self setUpChildControllerWith:[[AroundViewController alloc] init] norImage:[UIImage imageNamed:@"tab_0006_首页_点击.png"] selImage:[UIImage imageNamed:@"小区商务状态@2x.png"] title:@"小区商务"];
    
    [self.tabBarItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal  ];
    

    
    /** 设置tabar工具条 */
   // [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbar-light"]];
}
- (IBAction)fanhui:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}



- (void)setUpChildControllerWith:(UIViewController *)childVc norImage:(UIImage *)norImage selImage:(UIImage *)selImage title:(NSString *)title
{
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVc];
    
    childVc.title = title;
    
    childVc.tabBarItem.image = norImage;
    childVc.tabBarItem.selectedImage = selImage;
    
    [self addChildViewController:nav];
    
}

@end
